package com.zeroup.matrix.adapter;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.os.AsyncTask;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.VideoView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.blankj.utilcode.util.ScreenUtils;
import com.blankj.utilcode.util.StringUtils;
import com.cy.cyflowlayoutlibrary.FlowLayoutAdapter;
import com.zeroup.matrix.R;
import com.zeroup.matrix.bean.MGanVideo;
import com.zeroup.matrix.cache.DiskCache;
import com.zeroup.matrix.cache.ImageCache;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class VediosAdapter extends FlowLayoutAdapter<MGanVideo> {

    Activity activity;

    DiskCache cache = null;



    public VediosAdapter( Activity activity,List<MGanVideo> list_bean) {
        super(list_bean);
        this.activity = activity;
//        this.cache = new ImageCache(activity);

        this.cache = new DiskCache(activity,10*1024);
    }


    @Override
    public void bindDataToView(ViewHolder holder, int position, MGanVideo bean) {
        //视图绑定
        TextView textView = holder.getView(R.id.tvTitle);
        textView.setText(bean.getPushCopywriting());
        TextView tvContent = holder.getView(R.id.tvContent);
        tvContent.setText(bean.getTags());

        ImageView imageView = holder.getView(R.id.iv);
        if(!StringUtils.isEmpty(bean.getVideoThirdUrl())){
//            this.cache.loadImageIntoImageView(bean.getVideoThirdUrl(),imageView);
            this.cache.saveBitmap(bean.getVideoThirdUrl(),imageView);
        }

    }

    @Override
    public void onItemClick(int position, MGanVideo bean) {
            //点击事件
    }

    @Override
    public int getItemLayoutID(int position, MGanVideo bean) {
        return R.layout.gvedio_item;
    }




}
